From 3897868db104b88f70569a22613829031fa64f5c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 31 Mar 2015 00:59:40 -0700 Subject: [PATCH] resourceloader: Cut down on file stat time in safeFilemtime() * If stat cache is not enabled, this used to do two queries. Change-Id: Icfed675b27f952ec13b9d0af3e345b1486ea7c8f --- includes/resourceloader/ResourceLoaderModule.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index d689044019..572428e6bb 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -636,9 +636,10 @@ abstract class ResourceLoaderModule { * @return int UNIX timestamp */ protected static function safeFilemtime( $filename ) { - if ( !file_exists( $filename ) ) { - return 1; - } - return filemtime( $filename ); + wfSuppressWarnings(); + $mtime = filemtime( $filename ) ?: 1; + wfRestoreWarnings(); + + return $mtime; } } -- 2.20.1